package net.lzzy.practices.entities;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author m
 */
@Entity
@Getter
@Setter
//课程类
public class Course extends BaseEntity{
    private  String name;
    private  String description;
    private  String cover;

    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;
    private  boolean open;

    @ManyToOne   //对应关系 添加关联  1对多  一个老师可以上多个课程
    // 老师用户
    private User teacher;

    @ManyToMany
    private List<User> students= new ArrayList<>();

    @OneToMany(mappedBy = "course")
    private  List<Chapter> chapters = new ArrayList<>();
    @OneToMany(mappedBy = "course")
    private  List<Applicant> applicants = new ArrayList<>();
    public  Course(){
        createTime=new Date();
        updateTime=new Date();

    }

}
